package cz.possoft.client.saveload;

import java.io.Serializable;

import cz.possoft.serializable.generic.Game;

/**
 * This is abstraction for managing saving and loading different types of games.
 * 
 * @author mposolda
 */
public interface SaveLoadExecutor {
	
	/**
	 * This will save the given game to file defined by filename. The representation of game inside the file is dependent on SaveLoadManager implementation.
	 * So various formats (Binary, text) can be used. Important assumption is that game is saved to file with same SaveLoadManager, which will used for loading.
	 * 
	 * @param game
	 * @param fileName
	 */
	public <E extends Game> void saveGame(E game, String fileName) throws SaveLoadException;
	
	/**
	 * This will load game from file defined by filename. The representation of game inside the file is dependent on SaveLoadManager implementation.
	 * So various formats (Binary, text) can be used. Important assumption is that game was saved to file with same SaveLoadManager, which is used for loading.
	 * If correct format is not recognized in file, than BadGameFormatException should be thrown.
	 * 
	 * @param fileName
	 * @return
	 */
	public Game loadGame(String fileName) throws SaveLoadException;
	
	/**
	 * Get object for server when source is Game. Implementation can send game itself or some other object (some form of serialized Game etc)
	 * 
	 * @param game
	 * @throws SaveLoadException
	 */
	public Serializable getObjectForSendingToServer(Game source) throws SaveLoadException;
	
	/**
	 * get Game from object received from server. Source can be game itself for some implementations but also only String or XML for other implementations.
	 * 
	 * @param source
	 * @return
	 * @throws SaveLoadException
	 */
	public Game getGameFromServer(Serializable source) throws SaveLoadException;
}
